<?php
/**
 * 上传控制
 */

namespace app\admin\controller;

use app\common\controller\Upload as BaseUpload;
use think\Request;

class Upload extends BaseUpload
{

    /**
     * 上传图片
     * @param  string $filename [description]
     * @return [type]           [description]
     */
    public function image($filename = 'file')
    {
        $info = parent::image($filename);
        if (!is_string($info)) {
            $data = [
                'info'     => $info->getInfo(),     //文件信息
                'filename' => $info->getFileName(), //保存的文件名
                'savename' => $info->getSaveName()  //文件的路径
            ];
            $res = ['code' => 1,'msg' => '上传成功' , 'data' => $data];
        } else {
            $res = ['code' => 0,'msg' => $info ?: '上传失败'];
        }
        return $res;
    }
}